package top.buyibuyi.course.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.buyibuyi.course.R;
import top.buyibuyi.course.pojo.Classroom;
import top.buyibuyi.course.pojo.Crstate;
import top.buyibuyi.course.service.SelectClassroomService;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/course")
public class SelectClassroomController {

    @Autowired
    private SelectClassroomService selectClassroomService;

    @GetMapping("/selectFloor")
    public R selectFloor(){
        try {
            List<Classroom> classrooms = selectClassroomService.selectClassromAll();
            return R.ok().data("data",classrooms);
        }catch (Exception e){
            e.printStackTrace();
            return R.error();
        }
    }


    @GetMapping("/selectClassrooms/{id}")
    public R selectClassrooms(@PathVariable int id){
        try {
            List<Classroom> classrooms = selectClassroomService.selectclassrooms(id);
            return R.ok().data("data",classrooms);
        }catch (Exception e){
            e.printStackTrace();
            return R.error();
        }
    }
}
